package com.jngreen.crawler;

import java.io.FileInputStream;
import java.net.URL;
import java.util.Map;

import org.yaml.snakeyaml.Yaml;

public class YamlReader {

	@SuppressWarnings("rawtypes")
	public static Map readYaml(String file) {
		//TODO 读取配置优化
		try {
			Yaml yaml = new Yaml();
			URL url = YamlReader.class.getClassLoader()
					.getResource(file);
			if (url != null) {
				// 也可以将值转换为Map
				Map map = (Map) yaml.load(new FileInputStream(url.getFile()));
				return map;
			}
			return null;
		} catch (Exception e) {
			e.printStackTrace();
			return null;
		}
	}

	public static void main(String[] args) {

	}

}
